package edu.auctionmart

import static org.junit.Assert.*
import org.junit.*

class UserIntegrationTests {

    void testUserAccount() {
		User validAccount = new User(username: "Russell", userRealName: "administrator", passwd: "Testinga4b", email: "russell@maine.edu")
		validAccount.save()
		
		//invalid password, won't save
		User invalidAccount = new User(username: "Russell",  userRealName: "administrator", passwd: "abc", email: "russell@maine.edu")
		invalidAccount.save()
		
		def foundAccount = User.get(validAccount.id)
		assertNotNull(foundAccount)
		
		def notFound = User.get(invalidAccount.id)
		assertNull(notFound)
		
		Location testLocation = new Location(name: "Russell Gillen", addressLine: "50 USM Street", zipCode: "04103", town: "Portland", state: "ME")		
		Profile validProfile = new Profile(contactPhoneNumber: 2074503879, contactEmail: "rhgillen@gmail.com")
		validProfile.addToAddresses(testLocation)
		
		validAccount.profile = validProfile
		validProfile.save()
		
		foundAccount = User.get(validAccount.id)
		
		assertNotNull(foundAccount.profile)
		assertEquals 1, foundAccount.profile.addresses.size()
		
		
	}
}